
import './index.scss';
import { Component } from 'react';
import { Link } from 'react-router-dom';



import { MainHeader, MainContent } from 'templates/MainLayout/MainLayout';
import { EnumModalType } from 'constants/EnumType';


import {
    Tabs, Button, Input, Icon, Modal, Form,
} from 'antd';
const TabPane = Tabs.TabPane;

import T from 'utils/T';
import CesiumUtil from './CesiumUtil';
import {getTileServiceProvider} from './cesium';

import Color from 'cesium/core/Color';
const color = Color.fromRandom();
import 'cesium/Widgets/widgets.css';

export default class Cesium_map extends Component {
    constructor(props) {
        super(props);
        this.state = {

        };
        this.cesiumUtil = CesiumUtil;
    }

    componentDidMount() {
        this.$cesium = $('<div id="cesiumContainer"/>')
            .css({
                width: '100%',
                height: '100%',
                margin: 0,
                padding: 0,
                overflow: 'hidden'
            })
            .appendTo(this.cesiumBox);
        this.renderMap();
    }

    renderMap() {
        this.cesiumUtil = new CesiumUtil(this.$cesium[0], {
            // imageryProvider: new CesiumUtil.Cesium.UrlTemplateImageryProvider({
            //     url: getTileServiceProvider("Google.Satellite.Map"),
            //     maximumLevel: 5
            // }), //图像图层提供者
            // imageryProvider: new CesiumUtil.Cesium.SingleTileImageryProvider({
            //     url: earth,
            //     // rectangle : Cesium.Rectangle.fromDegrees(-75.0, 28.0, -67.0, 29.75)
            // })
        });
    }

    getDefaultData() {
        return [
            {
                'fromName': '成都',
                'toName': '墨尔本',
                'fromLon': 104.0642904524,
                'fromLat': 30.5752583808,
                'toLon': 144.9630576000,
                'toLat': -37.8136276000
            },
            {
                'fromName': '武汉',
                'toName': '成都',
                'fromLon': 114.3000994801,
                'fromLat': 30.5952549331,
                'toLon': 104.0642904524,
                'toLat': 30.5752583808
            },
            {
                'fromName': '重庆',
                'toName': '浦东',
                'fromLon': 106.9083564325,
                'fromLat': 29.4345249410,
                'toLon': 121.5400767367,
                'toLat': 31.2236364770
            },
            {
                'fromName': '杭州',
                'toName': '保山',
                'fromLon': 120.1503814986,
                'fromLat': 30.2764098092,
                'toLon': 99.1608329557,
                'toLat': 25.1148925002
            },
            {
                'fromName': '重庆',
                'toName': '甲米',
                'fromLon': 106.9083564325,
                'fromLat': 29.4345249410,
                'toLon': 98.9062835000,
                'toLat': 8.0862997000
            }
        ];
    }


    render() {


        return (
            <div ref={box => (this.cesiumBox = box)} className={'cesium_box'} />
        );
    }
}

